package com.lou.springboot.service.impl;

import com.lou.springboot.common.PageResult;
import com.lou.springboot.dao.TrackMapper;
import com.lou.springboot.dao.TrackMapperCustom;
import com.lou.springboot.entity.Track;
import com.lou.springboot.service.TrackService;
import com.lou.springboot.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class TrackServiceImpl implements TrackService {

    @Autowired
    private TrackMapperCustom trackMapperCustom;
    @Autowired
    private TrackMapper trackMapper;
    @Override
    public PageResult getTrackList(PageUtil pageUtil) {
        Map map = new HashMap(pageUtil);
        List<Track> tracks = trackMapperCustom.getTrackList(map);
        int total = trackMapperCustom.getTotalCount();
        PageResult pageResult = new PageResult(tracks, total, pageUtil.getLimit(), pageUtil.getPage());
        return pageResult;
    }

    @Override
    public boolean addTrack(Track track) {
        return trackMapperCustom.insertSelectiveCustom(track) > 0;
    }
}
